function uifftview_MakeImROI
%UIFFTVIEW_MAKEIMROI Summary of this function goes here
%   Detailed explanation goes here

    h = uipreview_GetImage;
    h_size= size(get(h, 'cdata'));
    ax= get(h, 'parent');
    margin= [1 1 -2 -2]*10;
    imrect_pos= [0 0 h_size(2) h_size(1)] + margin;
    h_rect=imrect(ax, imrect_pos);
    set(h_rect, 'tag', 'uifftview_imroi');
    set(h_rect, 'visible', 'off');
    setResizable(h_rect, false);
    %setappdata(h_rect, 'Moveable', false);
    setappdata(h, 'FFTROIHandle', h_rect);
    
    %delete Context menu
    cmenu_obj = findobj(h_rect,'Type','line','-or','Type','patch');
    set(cmenu_obj, 'UIContextMenu', '');
    
    % Specify a position constraint function using makeConstrainToRectFcn 
    % to keep the rectangle inside the original Xlim and Ylim ranges.
    xlim= [0 imrect_pos(3)]+ imrect_pos(1);
    ylim= [0 imrect_pos(4)]+ imrect_pos(2);
    fcn = makeConstrainToRectFcn('imrect', xlim, ylim);
    setPositionConstraintFcn(h_rect,fcn); 
    
end

